package top.wardyan.wtask.tapd.util;

import java.sql.Timestamp;

import cn.hutool.core.lang.Console;
import top.wardyan.common.util.DateUtil;

public class WorkHourUtil {

	private static final cn.hutool.log.Log log = cn.hutool.log.Log.get();

	/**
	 * 计算当周应产出工时
	 * @param date
	 * @return
	 */
	public static Float calWeekWorkHour(Timestamp date) {
		Float rs = 0.0F;
		// 本周应产出工时从星期一中午12:00开始算 // 每满24小时就算多9个小时的应产出工时 // 暂时不考虑节假日等因素
		// 首先: 找出开始时间点	DateUtil.range(3)是从周日开始算的
		Timestamp begin = new Timestamp( DateUtil.range(3).getTime() + 1000 * 60 * 60 * 36 + 1);
		Timestamp now = DateUtil.getCurrentTimestamp();
		rs = (now.getTime() - begin.getTime()) * 1.0F / 1000 / 60 / 60 / 24 * 9;
		if(rs < 0) {
			rs = 0.0F;
		}
		return rs;
	}
	
	public static void main(String[] args) {
		Console.log(DateUtil.range(3));
		calWeekWorkHour(DateUtil.getCurrentTimestamp());
	}
}
